#include"head.h"


/*按性别统计人数*/
void Count_Gender(Information s[], int n)
{
	int sum1 = 0;
	int sum2 = 0;
	
	for (int i=0; i<n; i++)
	{
		if (strcmp(s[i].gender,"男")==0)
		{
			sum1++;
		}
		
		if (strcmp(s[i].gender,"女")==0)
		{
			sum2++;
		}
	}
	printf("男生人数为: %d\n",sum1);
	printf("女生人数为：%d\n",sum2);

	return;
}

/*按所属部门统计人数*/
void Count_section(Information s[], int n)
{
	fflush(stdin);
	char appoint_section[20];
	printf("请输入指定部门：");
	gets(appoint_section);
	
	int sum=0;
	int flag;
	
	for (int i=0; i<n; i++)
	{
		if(strcmp(s[i].section,appoint_section)==0)
		{
			flag=1;
			sum++;
		}
	}
	if (flag!=1)
	{
		printf("未找到！\n");
	}
	else
	{
		printf("该部门共有%d个人",sum);
	}
	
}

/*按文化程度统计人数*/
void Count_culturestandard(Information s[], int n)
{
	fflush(stdin);
	char appoint_culturestandard[20];
	printf("请输入指定的文化程度：");
	gets(appoint_culturestandard);
	
	int sum=0;
	int flag;
	for (int i=0; i<n; i++)
	{
		if(strcmp(s[i].culturestandard,appoint_culturestandard)==0)
		{
			sum++;
		}
	}
	if (flag!=1)
	{
		printf("未找到！\n");
	}
	else
	{
		printf("该文化程度的人共有%d个人",sum);		
	}

}

/*按民族统计人数*/
void Count_nation(Information s[], int n)
{
	fflush(stdin);
	char appoint_nation[20];
	printf("请输入指定民族：");
	gets(appoint_nation);
	
	int sum=0;
	int flag;
	for (int i=0; i<n; i++)
	{
		if(strcmp(s[i].nation,appoint_nation)==0)
		{
			flag=1;
			sum++;
		}
	}
	if (flag!=1)
	{
		printf("未找到！\n");
	}
	else
	{
		printf("该民族的人共有%d个人",sum);
	}
	
}

/*按加班时间统计人数*/
void Count_add_work(Information s[], int n)
{
	int appoint_add_work;
	printf("请输入指定的加班时间：");
	scanf("%d", &appoint_add_work);
	
	int sum=0;
	
	int flag;
	for (int i=0; i<n; i++)
	{
		if(s[i].add_work==appoint_add_work)
		{
			flag=1;
			sum++;
		}
	}
	if (flag!=1)
	{
		printf("未找到！\n");
	}
	else
	{
		printf("该月加班%d天的人共有%d个人", appoint_add_work, sum);
	}
	
}

/*按旷工时间统计人数*/
void Count_free_work(Information s[], int n)
{
	int appoint_free_work;
	printf("请输入指定的旷工时间：");
	scanf("%d", &appoint_free_work);
	
	int sum=0;
	int flag;
	for (int i=0; i<n; i++)
	{
		if(s[i].free_work,appoint_free_work==0)
		{
			flag=1;
			sum++;
		}
	}
	if (flag!=1)
	{
		printf("未找到！\n");
	}
	else
	{
		printf("该月旷工%d天的人共有%d个人", appoint_free_work, sum);
	}

}